<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<!-- Copyright 1997 The Open Group, All Rights Reserved -->
<title>sleep</title>
</head><body bgcolor=white>
<center>
<font size=2>
The Single UNIX &reg; Specification, Version 2<br>
Copyright &copy; 1997 The Open Group

</font></center><hr size=2 noshade>
<h4><a name = "tag_000_008_795">&nbsp;</a>NAME</h4><blockquote>
sleep - suspend execution for an interval of time
</blockquote><h4><a name = "tag_000_008_796">&nbsp;</a>SYNOPSIS</h4><blockquote>
<pre><code>

#include &lt;<a href="unistd.h.html">unistd.h</a>&gt;

unsigned int sleep(unsigned int <i>seconds</i>);
</code>
</pre>
</blockquote><h4><a name = "tag_000_008_797">&nbsp;</a>DESCRIPTION</h4><blockquote>
The
<i>sleep()</i>
function will cause the calling thread 
to be suspended from
execution until either the number of real-time seconds specified
by the argument
<i>seconds</i>
has elapsed or a signal is delivered to the calling thread 
and its action is to invoke a signal-catching function or to
terminate the process.
The suspension time may be longer than requested due to the
scheduling of other activity by the system.
<p>
If a SIGALRM signal is generated for the calling process during
execution of
<i>sleep()</i>
and if the SIGALRM signal is being ignored or blocked
from delivery, it is unspecified whether
<i>sleep()</i>
returns when the SIGALRM signal is scheduled.
If the signal is being blocked, it is also unspecified whether it
remains pending after
<i>sleep()</i>
returns or it is discarded.
<p>
If a SIGALRM signal is generated for the calling process during
execution of
<i>sleep()</i>,
except as a result of a prior call to
<i><a href="alarm.html">alarm()</a></i>,
and if the SIGALRM signal is not being ignored or
blocked from delivery, it is unspecified whether that signal has
any effect other than causing
<i>sleep()</i>
to return.
<p>
If a signal-catching function interrupts
<i>sleep()</i>
and examines or changes either the time a SIGALRM is
scheduled to be generated, the action associated with the SIGALRM
signal, or whether the SIGALRM signal is blocked from delivery,
the results are unspecified.
<p>
If a signal-catching function interrupts
<i>sleep()</i>
and calls
<i><a href="siglongjmp.html">siglongjmp()</a></i>
or
<i><a href="longjmp.html">longjmp()</a></i>
to restore an environment saved prior to the
<i>sleep()</i>
call, the action associated with the SIGALRM signal and the time
at which a SIGALRM signal is scheduled to be generated are
unspecified.
It is also unspecified whether the SIGALRM signal is blocked,
unless the process' signal mask is restored as part of the
environment.
<p>
Interactions between
<i>sleep()</i>
and any of
<i><a href="setitimer.html">setitimer()</a></i>,
<i><a href="ualarm.html">ualarm()</a></i>
or
<i><a href="usleep.html">usleep()</a></i>
are unspecified.
</blockquote><h4><a name = "tag_000_008_798">&nbsp;</a>RETURN VALUE</h4><blockquote>
If
<i>sleep()</i>
returns because the requested time has elapsed, the value returned will be
0.  If
<i>sleep()</i>
returns because of premature arousal due to delivery of a signal, the return
value will be the &quot;unslept&quot; amount (the requested time minus the time
actually slept) in seconds.
</blockquote><h4><a name = "tag_000_008_799">&nbsp;</a>ERRORS</h4><blockquote>
No errors are defined.
</blockquote><h4><a name = "tag_000_008_800">&nbsp;</a>EXAMPLES</h4><blockquote>
None.
</blockquote><h4><a name = "tag_000_008_801">&nbsp;</a>APPLICATION USAGE</h4><blockquote>
None.
</blockquote><h4><a name = "tag_000_008_802">&nbsp;</a>FUTURE DIRECTIONS</h4><blockquote>
None.
</blockquote><h4><a name = "tag_000_008_803">&nbsp;</a>SEE ALSO</h4><blockquote>
<i><a href="alarm.html">alarm()</a></i>,
<i><a href="getitimer.html">getitimer()</a></i>,
<i><a href="nanosleep.html">nanosleep()</a></i>,
<i><a href="pause.html">pause()</a></i>,
<i><a href="sigaction.html">sigaction()</a></i>,
<i><a href="sigsetjmp.html">sigsetjmp()</a></i>,
<i><a href="ualarm.html">ualarm()</a></i>,
<i><a href="usleep.html">usleep()</a></i>,
<i><a href="unistd.h.html">&lt;unistd.h&gt;</a></i>.
</blockquote><h4>DERIVATION</h4><blockquote>
Derived from Issue 1 of the SVID.
</blockquote><hr size=2 noshade>
<center><font size=2>
UNIX &reg; is a registered Trademark of The Open Group.<br>
Copyright &copy; 1997 The Open Group
<br> [ <a href="../index.html">Main Index</a> | <a href="../xshix.html">XSH</a> | <a href="../xcuix.html">XCU</a> | <a href="../xbdix.html">XBD</a> | <a href="../cursesix.html">XCURSES</a> | <a href="../xnsix.html">XNS</a> ]

</font></center><hr size=2 noshade>
</body></html>

